package top.eggcode.modules.user.model;

import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;

/**
 * Title:
 * Description: TODO
 * Date: 2021/5/10 14:06
 *
 * @author JiaQi Ding
 * @version 1.0
 */
@Data
public class SessionUserView {
    private String id;

    private String username;

    private String nickname;

    private String avatar;

    private Short sex;

    private String mobile;

    private LocalDateTime createdAt;

    private List<String> roles;

    private Set<String> powers;

    private List<String> menuPowers;

    public static SessionUserView build(UserBiz user) {
        SessionUserView view = new SessionUserView();

        view.setUsername(user.getUsername());
        view.setNickname(user.getNickname());
        view.setAvatar(user.getAvatar());
        view.setSex(Short.valueOf(user.getSex()));
        view.setMobile(user.getMobile());
        view.setCreatedAt(user.getCreatedAt());
        return view;
    }
}
